package com.csu.servlet;

import com.csu.entiry.BorrowInfo;
import com.csu.service.BookService;
import com.csu.service.BorrowInfoService;
import com.csu.service.impl.BookServiceImpl;
import com.csu.service.impl.BorrowInfoServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import com.alibaba.fastjson.JSON;

@WebServlet(name = "SearchBookNameByKeyServlet", urlPatterns = "/SearchBookNameByKeyServlet")
public class SearchBookNameByKeyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String key = req.getParameter("key");
        BookService bookService = new BookServiceImpl();
        List<String> stringList = bookService.searchName(key);

        String result = JSON.toJSONString(stringList);
//        System.out.println(result);
        resp.setContentType("text/json");
        PrintWriter out = resp.getWriter();
        out.println(result);
    }
}
